package cn.edu.jsu.nrs.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TbNewsType entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_news_type", catalog = "db_nrs")
public class NewsType implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer newsTypeId;
	private NewsType tbNewsType;
	private String name;
	private Set<NewsType> tbNewsTypes = new HashSet<NewsType>(0);
	private Set<News> tbNewses = new HashSet<News>(0);

	// Constructors

	/** default constructor */
	public NewsType() {
	}

	/** minimal constructor */
	public NewsType(String name) {
		this.name = name;
	}

	/** full constructor */
	public NewsType(NewsType tbNewsType, String name,
			Set<NewsType> tbNewsTypes, Set<News> tbNewses) {
		this.tbNewsType = tbNewsType;
		this.name = name;
		this.tbNewsTypes = tbNewsTypes;
		this.tbNewses = tbNewses;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "news_type_id", unique = true, nullable = false)
	public Integer getNewsTypeId() {
		return this.newsTypeId;
	}

	public void setNewsTypeId(Integer newsTypeId) {
		this.newsTypeId = newsTypeId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id")
	public NewsType getTbNewsType() {
		return this.tbNewsType;
	}

	public void setTbNewsType(NewsType tbNewsType) {
		this.tbNewsType = tbNewsType;
	}

	@Column(name = "name", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbNewsType")
	public Set<NewsType> getTbNewsTypes() {
		return this.tbNewsTypes;
	}

	public void setTbNewsTypes(Set<NewsType> tbNewsTypes) {
		this.tbNewsTypes = tbNewsTypes;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbNewsType")
	public Set<News> getTbNewses() {
		return this.tbNewses;
	}

	public void setTbNewses(Set<News> tbNewses) {
		this.tbNewses = tbNewses;
	}

}